package graphics.object.testing;

import org.newdawn.slick.Color;

import graphics.TestingGraphics;
import graphics.object.GLTextRectangle;
import graphics.object.interfaces.GLMouseListener;

public class GLMouseInfoTextRect extends GLTextRectangle implements GLMouseListener{

	private static final long serialVersionUID = 1L;
	
	public Color textolor = new Color(255, 255, 255);
    public Color hoverColor = new Color(200, 200, 200);
    public Color renderColor;

    private boolean isSelected = false;

    public GLMouseInfoTextRect(int x, int y){
        super("", x, y);
        renderColor = textolor;
    }

    public void onRender() {
        TestingGraphics.font.drawString(x, y, text, renderColor);
    }

    public void onMouseMove(int x, int y, int dx, int dy) {
        if(contains(x, y)){
            renderColor = hoverColor;
        }else{
            renderColor = textolor;
        }

        if(isSelected){
            this.x += dx;
            this.y -= dy;
        }
        
        text = "MousePos: x: " + x + " y: " + y;
        width = TestingGraphics.font.getWidth(text);
        height = TestingGraphics.font.getHeight(text);
    }

    public void onMousePress(int id, int x, int y) {
        if(contains(x, y) && id == 0){
            isSelected = true;
        }
    }

    public void onMouseRelease(int id, int x, int y) {
        if(isSelected && id == 0){
            isSelected = false;
        }
    }
}
